﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Model;
using Eis51.CampanyCMS.Model.Bus;
using Eis51.CampanyCMS.Business.Bus;
using Eis51.CampanyCMS.FrameWork;
using Eis51.Web.Admin;

namespace Eis51.CampanyCMS.WebUI.Admin.Order
{
    public partial class MyPaymentPage : BasePage
    {
        // NewsID 0:新增/否则修改
        /// </summary>
        private string seqno
        {
            get
            {
                if (Request["seqno"] == null)
                {
                    return "0";
                }
                else
                {
                    return (string)Request["seqno"];
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                PaymentapiBLL.GetInstance().BindData(drpPaycode); 
                if (this.seqno != "0")
                {
                    Mypayment mypayment = MypaymentBLL.GetInstance().Get(new Mypayment.Key(int.Parse(this.seqno)));
                    if (mypayment != null)
                    {
                        UControl.CopyEntityToControl(this.Page.Form, mypayment);
                    }
                }
            }
        }


        protected void btnSave_Click(object sender, EventArgs e)
        {
            Mypayment mypayment = null;
            if (this.seqno != "0")
            {
                mypayment = MypaymentBLL.GetInstance().Get(new Mypayment.Key(int.Parse(this.seqno)));
            }
            else
            {
                mypayment = new Mypayment();
                mypayment.Createby = AppContext.CurrentAdministrator.Createby;
                mypayment.Createdate = DateTime.Now;
            }

            UControl.CopyControlToEntity(this.Page.Form, mypayment);
            
            MypaymentBLL.GetInstance().Subimt(mypayment);
            Response.Redirect("MyPaymentList.aspx");
        }
    }
}
